<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <!-- key是为了方便vue在更新的时候去复用元素的，提高性能 -->

      <!-- key只能使用数字和字符串 -->
      <!-- 同一组循环的key不能重复 -->

      <!-- 能不用index就不用index作为key -->

      <h2>通过 key 管理状态</h2>
      <ul>
        <li v-for="(item, index) in list" :key="item.id">{{ item.name }}</li>
      </ul>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const { createApp } = Vue;

      createApp({
        data() {
          return {
            list: [
              {
                id: 1,
                name: "xiaohua",
              },
              {
                id: 2,
                name: "zhangsan",
              },
              {
                id: 3,
                name: "xiaohua",
              },
            ],
          };
        },
      }).mount("#app");
    </script>
  </body>
</html>
